
#include <iostream>
#include <exception>
using namespace std;

//define two expections
class exa : public exception {
public:
  const char* what() const throw() {return "exa";}
};

class exb : public exception {
public:
  const char* what() const throw() {return "exb";}
};

void myunexpected()
{
  cout<<"myunexpected()"<<endl;
  throw exb();
}

void myfunc() throw(exb) 
{
  throw exa();
}

int main()
{
  set_unexpected(myunexpected);
  try {
    myfunc();
  }
  catch(exception& ex) {
    cout<<ex.what()<<endl;
  }
  catch(...){
    cout<<"catch all"<<endl;
  }
  return 0;
}
